package com.example.ribbonconsumer.hystrix;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Service
public class HelloServiceHystrix {

    @Resource
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "helloFallBack")
    public String helloService(){
        String url = "http://HELLO-SERVICE/eureka/client/hello";
        return restTemplate.getForEntity(url, String.class).getBody();
    }

    public String helloFallBack(){
        return "service Degradation";
    }
}
